package com.uni.exp4.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * --------------MyBatisFastUse-------------
 *
 * @Author Unirithe  - Mr.Chao
 * - CSDN:
 * https://blog.csdn.net/Unirithe
 * - GitHub:
 * https://github.com/unirithe
 * @create 2022/1/18 9:43
 * ------------------------------------------
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Printer {
    // 面向接口编程
    private Ink ink;
    private Paper paper;
    public void print(String str){
        int color = ink.getColor();
        System.out.println("使用: " + (color == 0 ? "无彩" : "彩色") + " 打印");
        // 输出字符到纸张
        for (int i = 0; i < str.length(); i++) {
            paper.printChar(str.charAt(i));
        }
        // 输出纸张内容
        System.out.println(String.format(
                (color== 0 ? "%s" : "\033[31m%s\033[0m"),
                paper.getContent()));
    }
}
